#pragma once

#include "ParameterSet.h"

#include "Constraint.h"
#include "Parameter.h"

namespace uml {

ParameterSet::ParameterSet(const QString& umlType)
    : NamedElement(umlType) {}

void ParameterSet::fromJson(const QJsonObject& json, QStringList& errorList) {
    if (json.isEmpty()) {
        return;
    }

    NamedElement::fromJson(json, errorList);
    JsonSerializable::fromJsonArray(conditions_, "conditions", json, errorList);
    JsonSerializable::fromJsonArray(parameters_, "parameters", json, errorList);
}

void ParameterSet::toJson(QJsonObject& json) {
    NamedElement::toJson(json);
    JsonSerializable::toJsonArray(conditions_, "conditions", json);
    JsonSerializable::toJsonArray(parameters_, "parameters", json);
}

/// <summary>
/// conditions getter
/// A constraint that should be satisfied for the owner of the Parameters in an
/// input ParameterSet to start execution using the values provided for those
/// Parameters, or the owner of the Parameters in an output ParameterSet to end
/// execution providing the values for those Parameters, if all preconditions and
/// conditions on input ParameterSets were satisfied.
/// </summary>
vector<shared_ptr<Constraint>>& ParameterSet::conditions() {
    return conditions_;
}

/// <summary>
/// parameters getter
/// Parameters in the ParameterSet.
/// </summary>
vector<shared_ptr<Parameter>>& ParameterSet::parameters() {
    return parameters_;
}

} // namespace uml
